package ads.server;

import java.util.NoSuchElementException;

import spread.MessageFactory;
import spread.SpreadException;
import spread.SpreadMessage;
import ads.util.GameInfo;
import ads.util.PlayerInfo;

public class ServerFifoMessageFactory extends MessageFactory {

	public ServerFifoMessageFactory(SpreadMessage message) {
		super(message);
	}

	@Override
	public SpreadMessage createMessage() {
		return super.createMessage();
	}

	public SpreadMessage createMessage(UpdateOperator operator, Object obj)
			throws SpreadException {
		if (obj instanceof PlayerInfo || obj instanceof GameInfo) {
			SpreadMessage msg = super.createMessage();
			UpdateMessageData msgdata = new UpdateMessageData(operator, obj);
			msg.setObject(msgdata);
			return msg;
		} else
			throw new NoSuchElementException();

	}

}
